/* // copy below to main to test
    let a = ch_034_find_the_first_palindrome__hard::find_first_palindrome(25, 10);
    assert_eq!(a, None);
*/
pub fn find_first_palindrome(start: i32, end: i32) -> Option<i32> {
    // TODO: Implement the function here
    let mut r: Option<i32> = None;
    let mut start = start;
    let mut end = end;
    if start > end {
        let t = start;
        start = end;
        end = t;
    }
    for n in start..=end {
        let sour = n.to_string();
        let rev: String = sour.chars().rev().into_iter().collect();
        if sour.eq(&rev) {
            r = Some(n);
            break;
        }
    }
    r
}

/* -- use i32 logic to reverse, will use low menmory.

pub fn reverse_int(n: i32) -> i32 {
    let mut n: i32 = n;
    let mut reversed: i32 = 0i32;
    while n != 0 {
        let digit = n % 10;
        reversed = reversed * 10 + digit;
        n = n / 10;
    }
    reversed
}

*/
